package com.atcumt.meituan;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

/* 
 * 按顺序给你一堆训练集（只有类别编号），给一个数组，每个类别中，
 * 前（类别数据个数）/2向上取整为训练集，后面的是测试集，让我们按顺序拆分
 */
public class Q4 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int[] arr = new int[n];
        Map<Integer, ArrayList<Integer>> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
            ArrayList<Integer> list = null;
            if (map.containsKey(arr[i])) {
                list = map.get(arr[i]);
                list.add(i);
            } else {
                list = new ArrayList<>();
                list.add(i);
            }
            map.put(arr[i], list);
        }
        List<Integer> resultTrain = new ArrayList<>();
        List<Integer> resultTest = new ArrayList<>();
        for (Map.Entry<Integer, ArrayList<Integer>> entry : map.entrySet()) {
            ArrayList<Integer> value = entry.getValue();
            int size = value.size();
            for (int i = 0; i < size; i++) {
                if (i < (size + 1) / 2) {
                    resultTrain.add(value.get(i));
                } else {
                    resultTest.add(value.get(i));
                }
            }
        }
        Collections.sort(resultTrain, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1 - o2;
            }
        });
        Collections.sort(resultTest, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1 - o2;
            }
        });
        for (Integer integer : resultTrain) {
            System.out.print(integer + " ");
        }
        System.out.println();
        for (Integer integer : resultTest) {
            System.out.println(integer + " ");
        }
        scanner.close();
    }
}
